package can;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 * Tests the determinePosition method by varying the values of each parameter individually.
 * 
 * @author Andrea
 * 
 */
public class TestConnellBotDeterminePosition {

  /**
   * Varies the angle passed into determinePosition to cover all equivalence classes.
   */
  @Test
  public void testAngle() {
    ConnellBot bot = new ConnellBot();

    // test the different possible angles
    assertEquals("Angle1", new ConnellBotPoint(200, 300), bot.determinePosition(0, 100, 200, 200));
    assertEquals("Angle2", new ConnellBotPoint(300, 200), bot.determinePosition(90, 100, 200, 200));
    assertEquals("Angle3", new ConnellBotPoint(200, 100),
        bot.determinePosition(180, 100, 200, 200));
    assertEquals("Angle4", new ConnellBotPoint(100, 200),
        bot.determinePosition(360, 100, 200, 200));
    assertEquals("Angle5", new ConnellBotPoint(270, 270), bot.determinePosition(45, 100, 200, 200));
    assertEquals("Angle6", new ConnellBotPoint(270, 129),
        bot.determinePosition(135, 100, 200, 200));
    assertEquals("Angle7", new ConnellBotPoint(129, 129),
        bot.determinePosition(225, 100, 200, 200));
    assertEquals("Angle8", new ConnellBotPoint(129, 270),
        bot.determinePosition(315, 100, 200, 200));
  }

  /**
   * Varies the distance passed into determinePosition to cover all equivalence classes.
   */
  @Test
  public void testDistance() {
    ConnellBot bot = new ConnellBot();
    assertEquals("Distance1", new ConnellBotPoint(200, 200),
        bot.determinePosition(45, 0, 200, 200));
    assertEquals("Distance2", new ConnellBotPoint(341, 341),
        bot.determinePosition(45, 200, 200, 200));
  }

  /**
   * Varies the origin passed into determinePosition to cover all equivalence classes.
   */
  @Test
  public void testOrigin() {
    ConnellBot bot = new ConnellBot();
    assertEquals("Origin1", new ConnellBotPoint(70, 70), bot.determinePosition(45, 100, 0, 0));
    assertEquals("Origin2", new ConnellBotPoint(570, 70), bot.determinePosition(45, 100, 500, 0));
    assertEquals("Origin3", new ConnellBotPoint(70, 570), bot.determinePosition(45, 100, 0, 500));
    assertEquals("Origin4", new ConnellBotPoint(570, 570),
        bot.determinePosition(45, 100, 500, 500));

  }
}
